package com.juzi.wopu.query;

import java.util.Date;

public class OrderQuery extends BaseQuery{
	private String type;
	
	private Long status;
	
	private Long companyCode;
	
	private Date beginDate;
	
	private Date endDate;

	public OrderQuery() {
		super("Order");
	}
	
	@Override
	protected void addWhere() {
	
		if (companyCode!=null && companyCode!=-1) {
			AddWhere("o.iCompany = ?", companyCode);
		}
		
		if (type!=null && !type.equals("") && !type.equals("-1")) {
			String[] strings=type.split(" - ");
			Long typeCode=Long.parseLong(strings[0]);
			Long subTypeCode=null;
			if(strings.length>1){
				subTypeCode=Long.parseLong(strings[1]);
			}
			if(typeCode!=null){
				AddWhere("o.iType = ?", typeCode);
			}
			if(subTypeCode!=null){
				AddWhere("o.iTypeSub = ?", subTypeCode);
			}
		}
		
		if(beginDate!=null && endDate!=null){
			AddWhere("o.dtRequest > ? and o.dtRequest < ?", beginDate, endDate);
		}
		
		if(status!=null && status!=-1L){
			AddWhere("o.iStatus = ?", status);
		}
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Long getCompanyCode() {
		return companyCode;
	}

	public void setCompanyCode(Long companyCode) {
		this.companyCode = companyCode;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Long getStatus() {
		return status;
	}

	public void setStatus(Long status) {
		this.status = status;
	}
}
